package mop.exception;

import mop.model.resource.Resource;
import mop.model.task.Task;

/**
 * Exception class for incorrect reservations
 * ergo start > than end
 * 
 * @author	 MOP Team 7
 */
public class IllegalReservationException extends Throwable 
{

	/**
	 * Initializes an IllegalReservationException with the passed resource and task
	 * 
	 * @param resource	The resource we want to reservate
	 * @param task		Task that wants to reservate resource
	 *  
	 * @post Task is set
	 * @post Resource is set
	 */
	public IllegalReservationException(Resource resource, Task task)
	{
		this.resource = resource;
		this.task = task;
	}
	
	/**
	 * Return a error message that can be used by the gui
	 * @return An error message describing the incorrect name
	 */
	public String toString()
	{
		StringBuffer sb = new StringBuffer();
		sb.append("Task "+ task.getId() + " can not make a reservation of resource "+ resource.getDescription() +"! \n");
		sb.append("This can happen if the task doesn't require the resource or has reached the limit for this resource");
		return sb.toString();
	}
	
	 
	/**
	 * Weird java demand
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * The task that makes the reservation
	 */
	private Task task;
	
	/**
	 * The resource that wants to make the reservation
	 */
	private Resource resource;
	
}
